﻿module lang.d.sts.declarations.ddeclaration;

import lang.d.sts.dsyntaxelement;

// TODO: Align, Pragma and Linkage attributes support
const uint NONE = 0;
const uint DEPRECATED = 1;
const uint PRIVATE = 2;
const uint PROTECTED = 4;
const uint PACKAGE = 8;
const uint PUBLIC = 16;
const uint EXPORT = 32;
const uint STATIC = 64;
const uint FINAL = 128;
const uint OVERRIDE = 256;
const uint ABSTRACT = 512;
const uint CONST = 1024;
const uint AUTO = 2048;
const uint SCOPE = 4096;
const uint GSHARED = 8192;
const uint SHARED = 16384;
const uint IMMUTABLE = 32768;
const uint EXTERN = 65536;
const uint NOTHROW = 131072;
const uint PURE = 262144;
const uint SYNCHRONIZED = 524288;


abstract class DDeclaration: DSyntaxElement {
    protected uint myAttribute;

    public this(in uint attribute) {
        myAttribute = attribute;
    }

    public bool isAttributeSet(in uint attribute) {
        return (myAttribute & attribute) != 0;
    }

    public bool isOwnAttributeSet(in uint attribute) {
        DDeclaration parentDeclaration = getParentDeclaration();
        if (parentDeclaration is null) {
            return isAttributeSet(attribute);
        }
        uint ownAttribute = myAttribute ^ parentDeclaration.myAttribute;
        return (attribute & ownAttribute) != 0;
    }
}
